﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebInvoicingsys.basecontrol
{
    public partial class uc_from_notice : System.Web.UI.UserControl
    {
        private void bind()
        {
            ddlist.Items.Add(new ListItem("请选择通知范围", ""));
            ddlist.Items.Add(new ListItem("部门", "1"));
            ddlist.Items.Add(new ListItem("公司", "0"));

            ddlist.SelectedIndex = 0;
        }

        public string getValue()
        {
            return ddlist.SelectedValue.ToString();
        }

        public string getText()
        {
            return ddlist.Text;
        }

        public void Reset()
        {
            ddlist.SelectedIndex = 0;
        }

        public void SetByValue(string value)
        {
            try
            {
                ddlist.ClearSelection();
                ddlist.Items.FindByValue(value).Selected = true;
            }
            catch
            {
                ddlist.ClearSelection();
                ddlist.SelectedIndex = 0;
            }
        }

        public void SetByText(string text)
        {
            try
            {
                ddlist.ClearSelection();
                ddlist.Items.FindByText(text).Selected = true;
            }
            catch
            {
                ddlist.ClearSelection();
                ddlist.SelectedIndex = 0;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
    }
}